// 修复角色节点模板的代码片段
// 将此代码替换到 u-index.html 文件中的角色节点模板部分

// 定义角色节点模板（小人形状）- 黑白配色
myDiagram.nodeTemplateMap.add("Entity",
  $(go.Node, "Auto",
    {
      locationSpot: go.Spot.Center,
      selectionAdorned: true,
      resizable: false,
      layoutConditions: go.Part.LayoutStandard & ~go.Part.LayoutNodeSized,
      // 设置角色的连接点为右侧，解决乱线问题
      fromSpot: go.Spot.Right,
      toSpot: go.Spot.Left
    },
    new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
    $(go.Panel, "Vertical",
      {
        // 为整个面板设置连接点
        portId: "",
        fromSpot: go.Spot.Right,
        toSpot: go.Spot.Left
      },
      // 小人的头部（圆形）
      $(go.Shape, "Circle",
        {
          name: "HEAD",
          width: 24,
          height: 24,
          fill: "#FFFFFF",
          stroke: "#000000",
          strokeWidth: 2,
          margin: new go.Margin(0, 0, 5, 0)
        },
        new go.Binding("fill", "isHighlighted", function(h) {
          return h ? "#F0F0F0" : "#FFFFFF";
        }).ofObject()
      ),
      // 小人的身体（线条组合）
      $(go.Panel, "Position",
        {
          width: 50,
          height: 60,
          background: "transparent"
        },
        // 身体
        $(go.Shape,
          {
            name: "BODY",
            geometryString: "M25,0 L25,35",
            stroke: "#000000",
            strokeWidth: 3
          }
        ),
        // 左臂
        $(go.Shape,
          {
            name: "LEFT_ARM",
            geometryString: "M25,12 L12,25",
            stroke: "#000000",
            strokeWidth: 2
          }
        ),
        // 右臂
        $(go.Shape,
          {
            name: "RIGHT_ARM",
            geometryString: "M25,12 L38,25",
            stroke: "#000000",
            strokeWidth: 2
          }
        ),
        // 左腿
        $(go.Shape,
          {
            name: "LEFT_LEG",
            geometryString: "M25,35 L12,55",
            stroke: "#000000",
            strokeWidth: 2
          }
        ),
        // 右腿
        $(go.Shape,
          {
            name: "RIGHT_LEG",
            geometryString: "M25,35 L38,55",
            stroke: "#000000",
            strokeWidth: 2
          }
        )
      ),
      // 角色名称
      $(go.TextBlock,
        {
          name: "TEXT",
          textAlign: "center",
          font: "bold 14px Inter, sans-serif",
          stroke: "#000000",
          margin: new go.Margin(8, 0, 0, 0),
          maxSize: new go.Size(100, NaN),
          wrap: go.TextBlock.WrapFit,
          editable: false
        },
        new go.Binding("text", "text")
      )
    )
  )
);